package com.nf.health.app.utils;

import android.text.TextUtils;

import com.nf.health.app.inquiry.adapter.SelectServiceDataTypeAdapter;
import com.nf.health.app.inquiry.bean.MySeltctPayTime;
import com.nf.health.app.intervention_details.adapter.MeridianAdapter;
import com.nf.health.app.intervention_details.adapter.MusicAdapter;
import com.nf.health.app.intervention_details.bean.Meridian;
import com.nf.health.app.intervention_details.bean.MusicBean;
import com.nf.health.app.models.ServicreDateType;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Jason on 2016/10/11.
 */
public class ModelUtils  {
    public static List<MySeltctPayTime> getMyAllServiceList(ServicreDateType servicreDateType) {
        List<MySeltctPayTime> list = new ArrayList<>();
        if(servicreDateType == null){
            return null;
        }
        if(servicreDateType.getMoney01() >= 0){
            MySeltctPayTime mySelectpayTime = new MySeltctPayTime();
            mySelectpayTime.setSelestDate("单次");//单次
            mySelectpayTime.setMoney(String.valueOf(servicreDateType.getMoney01()));//设置金额
            list.add(mySelectpayTime);
        }
        if(servicreDateType.getMoney02() >=  0){
            MySeltctPayTime mySelectpayTime = new MySeltctPayTime();
            mySelectpayTime.setMoney(String.valueOf(servicreDateType.getMoney02()));//设置金额
            mySelectpayTime.setSelestDate("次");//天次
            list.add(mySelectpayTime);
        }
        if(servicreDateType.getMoney03() >=  0){
            MySeltctPayTime mySelectpayTime = new MySeltctPayTime();
            mySelectpayTime.setMoney(String.valueOf(servicreDateType.getMoney03()));//设置金额
            mySelectpayTime.setSelestDate("周");//周
            list.add(mySelectpayTime);
        }
        if(servicreDateType.getMoney04() >=  0){
            MySeltctPayTime mySelectpayTime = new MySeltctPayTime();
            mySelectpayTime.setMoney(String.valueOf(servicreDateType.getMoney04()));//设置金额
            mySelectpayTime.setSelestDate("月");//月
            list.add(mySelectpayTime);
        }
        if(servicreDateType.getMoney05() >=  0){
            MySeltctPayTime mySelectpayTime = new MySeltctPayTime();
            mySelectpayTime.setMoney(String.valueOf(servicreDateType.getMoney05()));//设置金额
            mySelectpayTime.setSelestDate("季");//季
            list.add(mySelectpayTime);
        }
        if(servicreDateType.getMoney06() >=  0){
            MySeltctPayTime mySelectpayTime = new MySeltctPayTime();
            mySelectpayTime.setMoney(String.valueOf(servicreDateType.getMoney06()));//设置金额
            mySelectpayTime.setSelestDate("半年");//半年
            list.add(mySelectpayTime);
        }
        if(servicreDateType.getMoney07() >=  0){
            MySeltctPayTime mySelectpayTime = new MySeltctPayTime();
            mySelectpayTime.setMoney(String.valueOf(servicreDateType.getMoney07()));//设置金额
            mySelectpayTime.setSelestDate("年");//年
            list.add(mySelectpayTime);
        }
        if(servicreDateType.getMoney08() >=  0){
            MySeltctPayTime mySelectpayTime = new MySeltctPayTime();
            mySelectpayTime.setMoney(String.valueOf(servicreDateType.getMoney08()));//设置金额
            mySelectpayTime.setSelestDate("其他");//扩展字段
            list.add(mySelectpayTime);
        }
        if(servicreDateType.getMoney09() >=  0){
            MySeltctPayTime mySelectpayTime = new MySeltctPayTime();
            mySelectpayTime.setMoney(String.valueOf(servicreDateType.getMoney08()));//设置金额
            mySelectpayTime.setSelestDate("其他");//扩展字段
            list.add(mySelectpayTime);
        }

        return list;
    }
    public static void dealNotSelectStatus(List<MySeltctPayTime> list2,int index,SelectServiceDataTypeAdapter myAdapter){
        for (int i = 0; i < list2.size(); i++) {
            if(i != index){
                list2.get(i).setIsClick(false);
            }
        }
        myAdapter.setMyNotifyDataChanged(list2);
    }
    public static void dealNotSelectStatus2(List<MusicBean> list2,int index,MusicAdapter myAdapter){
        for (int i = 0; i < list2.size(); i++) {
            if(i != index){
                list2.get(i).setIsClick(false);
            }
        }
        myAdapter.notifyDataSetChanged();
    }
    public static void dealNotSelectStatus3(List<Meridian> list2,int index,MeridianAdapter myAdapter){
        for (int i = 0; i < list2.size(); i++) {
            if(i != index){
                list2.get(i).setIsClick(false);
            }
        }
        myAdapter.notifyDataSetChanged();
    }

    /**
     * @property (nonatomic,assign)buyType buytype ;
     * @property (nonatomic,assign)payType paytype ;
     * @return    2天/次，3周，4月，5季度，6半年，7一年
     */
    public static String getBuyType(String time){
        String result = "0";
        if(!TextUtils.isEmpty(time)){
            if(time.contains("次")){
                result = "2";
            }else if(time.contains("天")){
                result = "2";
            }else if(time.contains("周")){
                result = "3";
            }else if(time.contains("月")){
                result = "4";
            }else if(time.contains("季")){
                result = "5";
            }else if(time.contains("半年")){
                result = "6";
            }else if(time.equals("年")){
                result = "7";
            }
        }
        return result;
    }

    /**
     * 1 家庭服务 2 付费咨询 3健康管理
     * @param time
     * @return
     */
    public static  String getPayType(String time){
        String result = "0";
        if(!TextUtils.isEmpty(time)){
            if(time.contains("家庭医生")){
                result = "1";
            }else if(time.contains("付费咨询")){
                result = "2";
            }else if(time.contains("健康管理")){
                result = "3";
            }
        }
        return result;
    }

}
